{% extends "mall/base.html" %} {% block title %} {{ text }} {% endblock %} {%
block css %}
<link
  rel="stylesheet"
  href="{{ STATIC_URL }}/static/css/mall/goods-detail.css?v={{ version_code }}"
/>
<script type="text/javascript">
  window.onload = function() {
    if (window.name != "goods_detail") {
      location.reload();
      window.name = "goods_detail";
    } else {
      window.name = "";
    }
  };
</script>
{% endblock %} {% block header %} {% endblock %} {% block content %}
<input type="hidden" name="open_id" value="{{ open_id }}" />
<div
  class="swiper-container"
  data-space-between="10"
  data-pagination=".swiper-pagination"
  data-autoplay="1000"
>
  <div class="swiper-wrapper">
    {% for foo in goods_imgs %}
    <div
      class="swiper-slide"
      style="width: 100%;text-align: center;overflow: auto"
    >
      <img src="{{ foo }}" alt="" />
    </div>

    {% endfor %}
  </div>
  <div class="swiper-pagination swiper-pagination-bullets"></div>
</div>
<div id="part_main">
  {#
  <div class="inner" style="height: 320px;text-align: center;overflow: auto">
    #} {#
    <img id="firstImg" height="320" src="{{ goods.sdef_goods_thumbnail }}" />#}
    {# <img id="firstImg" height="320" src="{{ goods_imgs.0 }}" />#} {# #} {#
  </div>
  #}

  <div class="buy_area" id="buyArea">
    <div class="fn_wrap">
      <div class="fn_goods_name">
        <div class="fn_goods_name_main">{{ goods.sdef_goods_name }}</div>
        <a class="fn_goods_share" id="toShare" href="">
          <img src="/static/img/mall/share-icon.png" />
          <div>分享</div>
        </a>
        <img
          class="fn_goods_subImg"
          style="position: absolute;left: -9999999px;top: -9999999px;z-index: -1000;visibility: hidden;"
        />
      </div>
      <div class="desc right_shorter">{{ goods.sdef_goods_describe }}</div>
    </div>
    <div id="priceWrap">
      <div class="price_wrap" id="priceBlock">
        <span class="hide" id="priceTitle"></span>
        <span class="price" id="priceSale"
          >¥<em>{{ goods.sdef_goods_price }}</em></span
        >
      </div>
    </div>
    {% if is_membership %}
    <!-- <div class="user-price">VIP¥{{ goods.sdef_goods_member_price }}</div> -->
    {% endif %}
    <div class="de_pm">
      <div class="sku_container sku_container_on" id="skuCont">
        <div class="sku_add">
          <div class="sku_add_text">数量</div>
          <div class="sku_add_total">
            <span class="minus cart-count-control" data-value="-1">-</span
            ><input
              class="num"
              id="goodsCount"
              data-id="{{ goods.sdef_goods_id }}"
              type="text"
              readonly="readonly"
              value="1"
            /><span class="plus cart-count-control" data-value="1">+</span>
          </div>
        </div>
      </div>

      <div class="detail_gap"></div>
      <!--送货地址-->
      <div
        class="detail_gap"
        style="position: relative;width: 100%;    min-height: 100px"
      >
        <div class="weui-navbar">
          <div class="weui-navbar__item weui-bar__item_on" data-img="0">
            商品介绍
          </div>
          <div class="weui-navbar__item" data-img="1">
            恒温红酒
          </div>
          <div class="weui-navbar__item" data-img="2">
            特色服务
          </div>
        </div>
        <div
          id="divGoodsDetail"
          style="padding-top: 50px;text-align: center;color: grey"
        >
          {% if goods.sdef_goods_img_intro %} 加载中... {% else %} 暂无内容 {%
          endif %}
        </div>
      </div>
    </div>
  </div>
  <br />
  <br />
  <br />
  <br />
  <div class="de_btn_wrap fixed" id="btnTools">
    <div class="de_row de_btn_bar">
      <div
        class="icon_btn icon_cart_v2"
        onclick="location.href='/static/mall/index.html#/cart'"
      >
        <span class="add_num" id="popone">+1</span>
        <div id="divCartCount" class="txt">{{cart_count}}</div>
        <i class="icon"
          ><span class="num" id="cartNum" style="display: none">1</span></i
        >
      </div>
      {% if goods.sdef_goods_count > 0 %}
      <div class="de_span btn_group">
        <div class="de_row">
          <div class="btn btn_orange" id="addToCart">
            <span class="txt">加入购物车</span>
          </div>
          <div
            class="btn btn_buy"
            id="btnBuy"
            data-id="{{ goods.sdef_goods_id }}"
          >
            <span class="txt">立即购买</span>
          </div>
        </div>
      </div>
      {% elif goods.sdef_goods_count <= 0 %}
      <div class="de_span btn_group no_count">
        <div class="de_row">
          <div
            style="background: rgba(255, 150, 0, 0.5)"
            class="btn btn_orange"
          >
            <span class="txt">加入购物车</span>
          </div>
          <div style="background: rgba(228, 57, 60, 0.5)" class="btn btn_buy">
            <span class="txt">已售罄</span>
          </div>
        </div>
      </div>
      {% endif %}
    </div>
  </div>
</div>
{% endblock %} {% block footer %} {% endblock %} {% block js %}
<script>
  localStorage.removeItem("router");
  localStorage.setItem("router", "templates");
  console.log(localStorage.getItem("router"));
</script>
<script>
  var IMAGES = {{ goods_imgs }};
  var GOODS_TITLE = '{{ goods.sdef_goods_name }}';
  var GOODS_DECRIBE = '{{ goods.sdef_goods_describe }}'
  var GOODS_DETAIL_IMAGES = '{{ goods.sdef_goods_img_intro }}';
  var GOODS_ID = "{{ goods.sdef_goods_id }}";
  var LOADING_IMG = "{{ STATIC_URL }}/static/img/loading.gif";
  var MEMBERSHIP_GOODS_ID = "{{ membership_goods_id }}";
  var IS_MEMBERSHIP = "{{ is_membership }}";
  var SUBIMG = $('.fn_goods_subImg');
  $(".no_count").click(function () {
      showToast("商品已售罄");
  });

  SUBIMG.attr('src', '/static/share/goods/img/' + GOODS_ID + '.png')
        .on('error', function (err) {
            $("#toShare").hide()
        })
  $("#toShare").attr('href', '/static/share/goods/index.html?goodsId=' + GOODS_ID)
</script>
<script src="{{ STATIC_URL }}/static/js/mall/goods-detail.js?v={{ version_code }}5"></script>

{% if is_wechat %}
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>
  var debug = false;
  var appId = "{{ app_id }}";
  // 时间戳
  var timeStamp = "{{ time_stamp }}";
  // 随机字符串
  var nonceStr = "{{ nonce_str }}";
  var signature = "{{ signature }}";
  var link =
    "https://" +
    location.host +
    "/mall/detail/" +
    "{{ goods.sdef_goods_id }}" +
    "?oid=" +
    $("input[name=open_id]").val();

  $(function() {
    wx.config({
      debug: debug, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
      appId: appId, // 必填，公众号的唯一标识
      timestamp: timeStamp, // 必填，生成签名的时间戳
      nonceStr: nonceStr, // 必填，生成签名的随机串
      signature: signature, // 必填，签名，见附录1
      jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
    wx.ready(function() {
      wx.onMenuShareTimeline({
        title: "莱支好酒|{{ goods.sdef_goods_name }}", // 分享标题
        link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
        imgUrl: "{{ goods.sdef_goods_thumbnail|json_loads|get_item(0) }}", // 分享图标
        success: function() {
          // 用户确认分享后执行的回调函数
        },
        cancel: function() {
          // 用户取消分享后执行的回调函数
        }
      });
      wx.onMenuShareAppMessage({
        title: "莱支好酒|{{ goods.sdef_goods_name }}", // 分享标题
        desc: "{{ goods.sdef_goods_describe }}", // 分享描述
        link: link, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
        imgUrl: "{{ goods.sdef_goods_thumbnail|json_loads|get_item(0) }}", // 分享图标
        type: "link", // 分享类型,music、video或link，不填默认为link
        dataUrl: "", // 如果type是music或video，则要提供数据链接，默认为空
        success: function() {
          // 用户确认分享后执行的回调函数
        },
        cancel: function() {
          // 用户取消分享后执行的回调函数
        }
      });
    });
    wx.error(function(res) {
      alert("调用错误");
      alert(JSON.stringify(res));
    });

    function showDebug(k, v) {
      // 显示调试信息
      var html = "<p>";
      html += k + ":" + v;
      html += "</p>";
      $("#debug").append(html);
    }

    if (debug) {
      showDebug("appid", appId);
      showDebug("timeStamp", timeStamp);
      showDebug("nonceStr", nonceStr);
      showDebug("signature", signature);
    }
  });
</script>
{% endif %} {% endblock %}
